package demo;

import com.java.jvalidator.framework.ErrorMsg;
import com.java.jvalidator.framework.ValidationException;
import com.java.jvalidator.framework.ValidationFacade;
import com.java.jvalidator.framework.ValidationResult;

public class DemoMain {

	/**
	 * @param args
	 * @throws ValidationException
	 */
	public static void main(String[] args) throws ValidationException {
		Person p = new Person();
		p.setId("aa");
		p.setAdult(true);

		// 测试TypeUtil.getPropertyValue用
		// Object object = TypeUtil.getPropertyValue(p, "adult");
		// System.out.println(object);

		ValidationResult result = ValidationFacade.getInstance().validate(p);

		if (result.validationPassed()) {
			System.out.println("validate OK!");
		} else {
			for (ErrorMsg msg : result.getErrorMsg()) {
				System.out.println(msg.getValidateTarget().getClass().getName()
						+ "#" + msg.getPropertyName() + ":" + msg.getMessage());
			}
		}

	}

}
